package com.yonyou.crm.bpub.initdata.appctrl;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.yonyou.crm.bpub.initData.entity.InitDatasVO;
import com.yonyou.crm.bpub.initData.rmitf.IInitDatasRmService;
import com.yonyou.crm.common.exception.CrmMessageException;
import com.yonyou.crm.common.rest.util.RequestUtil;
import com.yonyou.crm.common.rest.util.ResponseUtil;
import com.yonyou.crm.common.security.util.Md5CodeUtil;

@RequestMapping("/{version}/*/{module}/initialdatas")
@RestController
public class AppInitDatasCtrl{
	
	@Autowired
	private IInitDatasRmService service;
	
	@RequestMapping(value="/{id}", method = RequestMethod.GET)
	public Object getInitData(@PathVariable("version") String version, @PathVariable("module") String module,@PathVariable("id") String id, HttpServletRequest request, HttpServletResponse response) throws CrmMessageException {
		
		JSONObject paramObj = RequestUtil.getParamObject(request);
		Map<String, String> param = new HashMap<String, String>();
		String subbnstype = "";
		if (paramObj.get("subbnstype") != null) {
			subbnstype = String.valueOf(paramObj.get("subbnstype"));
		}
		param.put("module",module);
		param.put("id",id);
		param.put("subbnstype",subbnstype);
		
		InitDatasVO initdata = service.getInitData(param);

		return ResponseUtil.getObject(initdata);
	}
	
}